Fix serialization when using interface as resource#2822
Conversation
| $propertyMetadata = $this->transformLinkStatus($propertyMetadata, $normalizationGroups, $denormalizationGroups); | ||
| } catch (ResourceClassNotFoundException $e) { | ||
| // No need to check link status if related class is not a resource | ||
| // hack to allow non-resource classes (actually they should not be supported) |
There was a problem hiding this comment.
If this hack is removed, all hell breaks loose, because we're using the PropertyMetadataFactory for input/output classes (DTOs). 😞
There was a problem hiding this comment.
Yes we done it on purpose. It's a good move actually, it allows to retrieve the shape of any PHP structure, regardless if it is mapped with @ApiResource or not.
There was a problem hiding this comment.
Okay, I'll update the comment. 😎
There was a problem hiding this comment.
But actually, I can see many problems with using the property metadata system like this. It's simply not designed for non-resources, as you can see here. It'd give the wrong results (as in this case), which is arguably worse than not using it at all.
There was a problem hiding this comment.
1071f97 to
075222c
Compare
075222c to
731b45f
Compare
731b45f to
a3fd33c
Compare
8330e42 to
8b5b129
Compare
8b5b129 to
f8e3011
Compare
f8e3011 to
50221f5
Compare
| $this->resourceMetadataFactory = $resourceMetadataFactory; | ||
| $this->serializerClassMetadataFactory = $serializerClassMetadataFactory; | ||
| $this->decorated = $decorated; | ||
| $this->resourceClassResolver = $resourceClassResolver; |
There was a problem hiding this comment.
Hmm... We need to do this in many places. Will do this in a follow-up PR?
50221f5 to
7bdb0f6
Compare
|
Build failures should be fixed by #2841 We shall re-trigger the build after that's merged. |
7bdb0f6 to
6a64d36
Compare
|
Build still failing, will be fixed by #2843 |
6a64d36 to
bba7e32
Compare
bba7e32 to
c9d9c58
Compare
|
nice :D @Nek- will be happy with this :D |
|
this has caused a regression for me and I can't seem to fix I have an operation which returns a different class to resources the operation is defined on. |
|
@bendavies Can you open an issue? |
|
@teohhanhui done. |
TODO: